package com.modern.devtools;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.io.IOException;

/**
 * JavaFX App - Main Application Entry Point
 * Initializes Spring context and starts the main UI
 */
public class MainApp extends Application {

    private static Scene scene;
    public static AnnotationConfigApplicationContext springContext;

    @Override
    public void start(Stage stage) throws IOException {
        // Initialize Spring context
        springContext = new AnnotationConfigApplicationContext();
        springContext.scan("com.modern.devtools");
        springContext.refresh();
        
        // Load main UI
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/main.fxml"));
        Parent root = loader.load();
        scene = new Scene(root, 1200, 800);
        stage.setTitle("Stardust Ops - Modern Server Management Platform");
        stage.setScene(scene);
        stage.show();
    }

    @Override
    public void stop() throws Exception {
        if (springContext != null) {
            springContext.close();
        }
        super.stop();
    }

    public static void main(String[] args) {
        launch();
    }

}